package com.srit.recipes.common.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class JwtUtil {
    private static final String SIGN_KEY ="recipesTokenSecret";  //密钥盐

    private static Algorithm ALGORITHM = Algorithm.HMAC256(SIGN_KEY);


    public static String generateToken(Long userId){

        return JWT.create()

                .withIssuer("recipes")

                .withIssuedAt(new Date(System.currentTimeMillis()))// 签发时间

//                .withExpiresAt(new Date(currentTime + EXPIRES_IN * 1000 * 60))// 过期时间戳

                .withClaim("userId", userId)//自定义参数

                .sign(ALGORITHM);
    }



}